@extends('common')
@section('content')
<br><br>
<form action="form-inline definewidth m20">
	<table class="">
		<tr>
			<td>
				职位
				<select name="" id="">
					<option value="">-选择-</option>
					<option value="">人事</option>
					<option value="">行政</option>
					<option value="">顾问</option>
					<option value="">教练</option>
				</select></td>
			<td>员工编号:<input type="text" placeholder="员工编号"></td>
			<td>姓名:<input type="text" placeholder="员工姓名"></td>
			<td>
				状态
				<select name="" id="">
					<option value="">-选择-</option>
					<option value="">待确认</option>
					<option value="">已确认</option>
					<option value="">待发放</option>
				</select>
			</td>
			<td><button type="submit">搜索</button></td>
		</tr>
	</table>
</form>
<table class="table table-bordered table-hover m10">
	<tr>
		<th align="center"  rowspan="2">岗位</th>
		<th align="center" rowspan="2">编号</th>
		<th align="center" rowspan="2">姓名</th>
		<th align="center" rowspan="2">出勤天数</th>
		<th align="center" colspan="5">应发工资</th>
		<th align="center" colspan="5">应扣工资</th>
		<th align="center" rowspan="2">实发工资(元)</th>
		<th align="center" rowspan="2">状态</th>
	</tr>
	<tr>
		<th align="center">基本工资</th>
		<th align="center">绩效奖金</th>
		<th align="center">全勤奖</th>
		<th align="center">补助</th>
		<th align="center">合计</th>
		<th align="center">请假</th>
		<th align="center">社保</th>
		<th align="center">公基金</th>
		<th align="center">个税</th>
		<th align="center">合计</th>
	</tr>
	@foreach($users as $key => $value)
		<tr a="{{$value['use_id']}}">
			<td>{{$value['use_position']}}</td>
			<td>{{$value['use_num']}}</td>
			<td>{{$value['use_name']}}</td>
			<td>{{30-$value['days']}}</td>
			<td>{{$value['wag_basic']}}</td>
			<td>{{$value['wag_bonus']}}</td>
			<td>{{$value['wag_subsidy']}}</td>
			<td>{{$value['wag_atten']}}</td>
			<td>{{$value['wag_basic']+$value['wag_bonus']+$value['wag_subsidy']+$value['wag_atten']}}</td>
			<td>{{$value['kouqingjia']}}</td>
			<td>20</td>
			<td>20</td>
			<td>20</td>
			<td>{{$value['kouqingjia']+60}}</td>
			<td>{{$states[$key]['s_actual']}}</td>
			<td>@if($states[$key]['s_state']==0)<input type="button" value="发工资" class="salary" num="{{$states[$key]['s_actual']}}">@else已发送@endif</td>
		</tr>
	@endforeach
</table>
<div class="inline pull-right page">
	{{$user['total']}} 条记录 {{$user['current_page']}}/{{$user['last_page']}} 页
	<a href='{{url('finance/salary')}}' >首页</a>
	<a href='{{$user['prev_page_url']}}'>上一页</a>
	@for($i=1;$i<=$user['last_page'];$i++)
		@if($i==$user['current_page'])
			<a href='{{url('finance/salary').'?page='.$i}}'><font color="red">{{$i}}</font></a>
		@else
			<a href='{{url('finance/salary').'?page='.$i}}'>{{$i}}</a>
		@endif
	@endfor
	<a href='{{$user['next_page_url']}}'>下一页</a>
	<a href='{{url('finance/salary').'?page='.$user['last_page']}}' >末页</a>
</div>
<script>
	$(function(){
		$('.salary').click(function(){
			$that=$(this);
			var num=$(this).attr('num');
			var use_id=$(this).parent().parent().attr('a');
			if(confirm('请确认执行此操作')){
				$that.attr('disabled','disabled');
				url="/finance/fa_salary";
				$.get(url,{use_id:use_id,num:num},function(msg){
					if(msg==100){
						str='已发送';
						$that.parent().html(str);
					}
				})
			}
		})
	})
</script>
@stop